<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body>
	<hr class="layui-bg-gray">
	<form class="layui-form" lay-filter="job-edit-form">
		<div class="layui-form-item">
			<input name="id" type="hidden" th:value="${task.id}">
			<label class="layui-form-label">任务名称：</label>
			<div class="layui-input-block">
				<input name="jobName" placeholder="请输入任务名称" autocomplete="off" class="layui-input"
					th:value="${task.jobName}" lay-verify="required">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">任务分组：</label>
			<div class="layui-input-block">
				<input name="jobGroup" placeholder="请输入任务分组" autocomplete="off" class="layui-input"
					th:value="${task.jobGroup}" lay-verify="required">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">任务类：</label>
			<div class="layui-input-block">
				<input name="beanClass" placeholder="请输入任务类" autocomplete="off" class="layui-input"
					th:value="${task.beanClass}" lay-verify="required">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">cron 式：</label>
			<div class="layui-input-block">
				<input name="cronExpression" placeholder="请输入cron表达式：" autocomplete="off" class="layui-input"
					th:value="${task.cronExpression}" lay-verify="required">
			</div>
		</div>
		<div class="layui-form-item layui-form-text">
			<label class="layui-form-label">任务描述：</label>
			<div class="layui-input-block">
				<textarea name="description" placeholder="请输入任务描述：" class="layui-textarea"
					th:text="${task.description}" lay-verify="required"></textarea>
				<!-- 任务状态 -->
				<input name="jobStatus" type="hidden" value="0" th:value="${task.jobStatus}">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit="" lay-filter="job-edit">立即提交</button>
			</div>
		</div>
	</form>
	<div th:include="include::footer"></div>
	<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
	<script>
		layui.use([ 'form', 'layedit', 'laydate' ], function() {
			var form = layui.form, layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate;
			var $ = layui.jquery;

			//监听提交
			form.on('submit(job-edit)', function(data) {
				//提交数据data.field
				$.ajax({
					cache : true,
					type : "POST",
					url : "/sys/task/update",
					data : data.field,
					async : false,
					error : function(request) {
						layer.alert("Connection error");
					},
					success : function(r) {
						if (r.retCode == '0000') {
							parent.layer.msg("保存成功");
							parent.location.reload(); // 父页面刷新
							var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
							parent.layer.close(index);
						} else {
							layer.alert(r.retMsg)
						}
					}
				});
				return false;
			});
		});
	</script>
</body>
</html>